
trait Logger{
  def log(message: String):Unit
}

class Calculator extends Logger {
  def log(message: String): Unit ={
    println(message)
  }
  def add(x:Int,y:Int): Unit ={
    val result=x+y
    log(s"Adding $x and $y .Result:$result")
  }
  def subtract(x: Int, y: Int): Unit ={
    val message1=("Subtracting %d from %d .Result:%d".format(y,x,x-y))
    val message2=("Subtracting %d from %d .Result:%d".format(x,y,y-x))
    if (x>y) log(message1) else log(message2)
  }
}
object Calculatortest {
  def main(args: Array[String]): Unit = {
    val calculator=new Calculator()
    calculator.add(10,5)
    calculator.subtract(5,10)
  }
}